package top.wu2020.lazy.ws.chat.application.impl;

import org.wu.framework.database.lazy.web.plus.stereotype.LazyApplication;
import top.wu2020.lazy.ws.chat.application.CommunityLikeRecordApplication;
import org.springframework.web.bind.annotation.*;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import top.wu2020.lazy.ws.chat.domain.model.community.like.record.CommunityLikeRecord;
import top.wu2020.lazy.ws.chat.application.command.community.like.record.CommunityLikeRecordRemoveCommand;
import top.wu2020.lazy.ws.chat.application.command.community.like.record.CommunityLikeRecordStoryCommand;
import top.wu2020.lazy.ws.chat.application.command.community.like.record.CommunityLikeRecordUpdateCommand;
import top.wu2020.lazy.ws.chat.application.command.community.like.record.CommunityLikeRecordQueryListCommand;
import top.wu2020.lazy.ws.chat.application.command.community.like.record.CommunityLikeRecordQueryOneCommand;
import top.wu2020.lazy.ws.chat.application.assembler.CommunityLikeRecordDTOAssembler;
import top.wu2020.lazy.ws.chat.application.dto.CommunityLikeRecordDTO;
import java.util.stream.Collectors;
import jakarta.annotation.Resource;
import top.wu2020.lazy.ws.chat.domain.model.community.like.record.CommunityLikeRecordRepository;
import java.util.List;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
/**
 * describe community_like_record 
 *
 * @author Jia wei Wu
 * @date 2024/05/24 08:52 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl 
 **/
@LazyApplication
public class CommunityLikeRecordApplicationImpl implements CommunityLikeRecordApplication {

    @Resource
    CommunityLikeRecordRepository communityLikeRecordRepository;
    /**
     * describe 新增
     *
     * @param communityLikeRecordStoryCommand 新增     
     * @return {@link Result<CommunityLikeRecord>} 新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Override
    public Result<CommunityLikeRecord> story(CommunityLikeRecordStoryCommand communityLikeRecordStoryCommand) {
        CommunityLikeRecord communityLikeRecord = CommunityLikeRecordDTOAssembler.INSTANCE.toCommunityLikeRecord(communityLikeRecordStoryCommand);
        return communityLikeRecordRepository.story(communityLikeRecord);
    }
    /**
     * describe 批量新增
     *
     * @param communityLikeRecordStoryCommandList 批量新增     
     * @return {@link Result<List<CommunityLikeRecord>>} 新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Override
    public Result<List<CommunityLikeRecord>> batchStory(List<CommunityLikeRecordStoryCommand> communityLikeRecordStoryCommandList) {
        List<CommunityLikeRecord> communityLikeRecordList = communityLikeRecordStoryCommandList.stream().map( CommunityLikeRecordDTOAssembler.INSTANCE::toCommunityLikeRecord).collect(Collectors.toList());
        return communityLikeRecordRepository.batchStory(communityLikeRecordList);
    }
    /**
     * describe 更新
     *
     * @param communityLikeRecordUpdateCommand 更新     
     * @return {@link Result<CommunityLikeRecord>} 领域对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Override
    public Result<CommunityLikeRecord> updateOne(CommunityLikeRecordUpdateCommand communityLikeRecordUpdateCommand) {
        CommunityLikeRecord communityLikeRecord = CommunityLikeRecordDTOAssembler.INSTANCE.toCommunityLikeRecord(communityLikeRecordUpdateCommand);
        return communityLikeRecordRepository.story(communityLikeRecord);
    }

    /**
     * describe 查询单个
     *
     * @param communityLikeRecordQueryOneCommand 查询单个     
     * @return {@link Result<CommunityLikeRecordDTO>} DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Override
    public Result<CommunityLikeRecordDTO> findOne(CommunityLikeRecordQueryOneCommand communityLikeRecordQueryOneCommand) {
        CommunityLikeRecord communityLikeRecord = CommunityLikeRecordDTOAssembler.INSTANCE.toCommunityLikeRecord(communityLikeRecordQueryOneCommand);
        return communityLikeRecordRepository.findOne(communityLikeRecord).convert(CommunityLikeRecordDTOAssembler.INSTANCE::fromCommunityLikeRecord);
    }

    /**
     * describe 查询多个
     *
     * @param communityLikeRecordQueryListCommand 查询多个     
     * @return {@link Result<List<CommunityLikeRecordDTO>>} DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Override
    public Result<List<CommunityLikeRecordDTO>> findList(CommunityLikeRecordQueryListCommand communityLikeRecordQueryListCommand) {
        CommunityLikeRecord communityLikeRecord = CommunityLikeRecordDTOAssembler.INSTANCE.toCommunityLikeRecord(communityLikeRecordQueryListCommand);
        return communityLikeRecordRepository.findList(communityLikeRecord)        .convert(communityLikeRecords -> communityLikeRecords.stream().map(CommunityLikeRecordDTOAssembler.INSTANCE::fromCommunityLikeRecord).collect(Collectors.toList())) ;
    }

    /**
     * describe 分页查询多个
     *
     * @param communityLikeRecordQueryListCommand 分页查询多个     
     * @return {@link Result<LazyPage<CommunityLikeRecordDTO>>} 分页DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Override
    public Result<LazyPage<CommunityLikeRecordDTO>> findPage(int size,int current,CommunityLikeRecordQueryListCommand communityLikeRecordQueryListCommand) {
        CommunityLikeRecord communityLikeRecord = CommunityLikeRecordDTOAssembler.INSTANCE.toCommunityLikeRecord(communityLikeRecordQueryListCommand);
        return communityLikeRecordRepository.findPage(size,current,communityLikeRecord)        .convert(page -> page.convert(CommunityLikeRecordDTOAssembler.INSTANCE::fromCommunityLikeRecord))            ;
    }

    /**
     * describe 删除
     *
     * @param communityLikeRecordRemoveCommand 删除     
     * @return {@link Result<CommunityLikeRecord>}      
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Override
    public Result<CommunityLikeRecord> remove(CommunityLikeRecordRemoveCommand communityLikeRecordRemoveCommand) {
     CommunityLikeRecord communityLikeRecord = CommunityLikeRecordDTOAssembler.INSTANCE.toCommunityLikeRecord(communityLikeRecordRemoveCommand);
     return communityLikeRecordRepository.remove(communityLikeRecord);
    }

}